<%@page language="java" isELIgnored="false" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<jsp:directive.include file="/WEB-INF/sitemesh-decorators/include.jsp"/>
<fmt:setBundle basename="bundles.facultyresearch-resources"/>
<html>
<head>
<title>Edit <fmt:message key="facultyresearch.title"/></title>
<script type="text/javascript">
$(function() {
	var facultyList = '${facultyList}';
	var facultyStr = facultyList.substring(facultyList.indexOf('{')+1,facultyList.indexOf('}'));
	facultyStr = facultyStr.replace(/=/g,":");
	var facultyArr=facultyStr.split(',');
	var tempArray = new Array();
	var tempStr="";
	for(var i=0;i<facultyArr.length;i++){
		tempStr = facultyArr[i];
		tempStr = tempStr.substring(tempStr.indexOf(":")+1);
		tempArray[i]= tempStr;
	}
	$( "#facultyName").autocomplete({
		source: tempArray,
		select: function(e, ui) {
			var faculty = ui.item.value;
			getId(faculty,facultyArr);
			$("#facultyName").val(faculty);
		},
	});
});
function getId(str,arr){
	var key = "";
	var value ="";
	var tempStr="";
	for(var i=0;i<arr.length;i++){
		tempStr = arr[i];
		tempStr = tempStr.replace(/^\s+|\s+$/g,'');
		key=tempStr.substring(0,tempStr.indexOf(":"));
		value = tempStr.substring(tempStr.indexOf(":")+1);
		if(value==str){
			$("#facultyresearch_faculty").val(key);
		}
	}
}
$().ready(function() {
	$('#facultyresearchform').validate();
	
});
$(document).ready(function() {
	//alert('${facultyName}');
	$("#facultyName").val('${facultyName}');
	$("#facultyresearch_faculty").val('${facultyId}');
	if('${facultyId}'==''){
		$('#facultyTitle').show();
		$('#facultyName').show();
		
	}else{
		$('#facultyTitle').hide();
		$('#facultyName').hide();
	}
		
	//alert($("#facultyName").val());	  
	});
</script>
</head>
<body>
<div id="contentarea">    
	<div id="lb"><div id="rb"><div id="bb"><div id="blc">
	<div id="brc"><div id="tb"><div id="tlc"><div id="trc">
	<div id="content">
		<h1><%-- <fmt:message key="navigation.edit"/> --%> <fmt:message key="facultyresearch.title"/></h1>
		<div class="navitem"><a class="button" href="${pageContext.request.contextPath}/indexFacultyresearch"><span><img src="includes/images/icons/back.gif" /><fmt:message key="navigation.back"/></span></a></div>
		<form:form id="facultyresearchform" action="${pageContext.request.contextPath}/saveFacultyresearch" method="POST" modelAttribute="facultyresearch">
			<form:hidden id="facultyresearch_facultyResearchId" path="facultyResearchId"/>
			<table cellpadding="0" cellspacing="0" id="viewTable">
				<tbody>
									
					<tr>
						<td class="label" valign="top">
							<fmt:message key="facultyresearch.title.title"/>:
						</td>
						<td>
							<form:input id="facultyresearch_title" path="title" cssStyle="width:300px;" class="required" />
							<!-- <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : "facultyresearch_title",widgetType : "dijit.form.ValidationTextBox",widgetAttrs : {promptMessage: "<fmt:message key="facultyresearch.title.help"/>"}})); </script> -->
						</td>
					</tr>
					<tr>
						<td class="label" valign="top">
							<fmt:message key="facultyresearch.researchdescription.title"/>:
						</td>
						<td>
							<form:textarea id="facultyresearch_researchDescription"  rows="5" path="researchDescription" cssStyle="width:300px;" class="required" />
							<!-- <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : "facultyresearch_researchDescription",widgetType : "dijit.form.ValidationTextBox",widgetAttrs : {promptMessage: "<fmt:message key="facultyresearch.researchdescription.help"/>"}})); </script> -->
						</td>
					</tr>
					<tr>
						<td class="label" valign="top">
							<fmt:message key="facultyresearch.researchstatus.title"/>:
						</td>
						<td>
							<form:input id="facultyresearch_researchStatus" path="researchStatus" cssStyle="width:300px;" class="required"/>
							<!-- <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : "facultyresearch_researchStatus",widgetType : "dijit.form.ValidationTextBox",widgetAttrs : {promptMessage: "<fmt:message key="facultyresearch.researchstatus.help"/>"}})); </script> -->
						</td>
					</tr>
					<tr>
						<td class="label" valign="top">
							<fmt:message key="facultyresearch.minumumrequirements.title"/>:
						</td>
						<td>
							<form:textarea id="facultyresearch_minumumRequirements" rows="5" path="minumumRequirements" cssStyle="width:300px;"/>
							<!-- <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : "facultyresearch_minumumRequirements",widgetType : "dijit.form.ValidationTextBox",widgetAttrs : {promptMessage: "<fmt:message key="facultyresearch.minumumrequirements.help"/>"}})); </script> -->
						</td>
					</tr>
					<tr>
						<td id="facultyTitle" class="label" valign="top">
							<fmt:message key="faculty.title"/>:
						</td>
						<td>
							<form:hidden id="facultyresearch_faculty" path="faculty"/>
							<input type="text" id="facultyName" class="required"/>
							<!-- <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : "facultyresearch_minumumRequirements",widgetType : "dijit.form.ValidationTextBox",widgetAttrs : {promptMessage: "<fmt:message key="facultyresearch.minumumrequirements.help"/>"}})); </script> -->
						</td>
					</tr>
				</tbody>
			</table>
			<span class="inputbutton"><input class="savebutton" id="save" type="submit" value="<fmt:message key="navigation.save"/>"/></span>
			<script type="text/javascript">Spring.addDecoration(new Spring.ValidateAllDecoration({elementId:'save', event:'onclick'}));</script>
		</form:form>
		<div class="clear">&nbsp;</div>
	</div>
	</div></div></div></div>
	</div></div></div></div>
</div>
</body>
</html>